package com.warren.context.event;

import com.warren.beans.factory.BeanFactory;
import com.warren.context.ApplicationEvent;
import com.warren.context.ApplicationListener;

/**
 * @author warren
 * @create 2021-08-22 16:32
 * @Description 简单的事件广播器
 */
public class SimpleApplicationEventMulticaster extends AbstractApplicationEventMulticaster{

    public SimpleApplicationEventMulticaster(BeanFactory beanFactory){
        setBeanFactory(beanFactory);
    }

    @SuppressWarnings("unchecked")
    @Override
    public void multicastEvent(ApplicationEvent event) {
        for (final ApplicationListener listener : getApplicationListener(event)){
            listener.onApplicationEvent(event);
        }
    }
}
